package com.mfangsoft.zhuangjialong.app.entryactivity.controller;





import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.facebook.presto.sql.parser.SqlBaseParser.UseContext;
import com.mfangsoft.zhuangjialong.app.entryactivity.model.BaseEntryActivity;
import com.mfangsoft.zhuangjialong.app.entryactivity.service.EntryActivityService;
import com.mfangsoft.zhuangjialong.common.context.UserContext;
import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.common.model.ResponseMessage;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;
import com.mfangsoft.zhuangjialong.common.utils.UserSessionUtil;
import com.mfangsoft.zhuangjialong.integration.activity.model.BaseActivityInfo;
import com.mfangsoft.zhuangjialong.integration.activity.model.BaseActivityInfoItem;
import com.mfangsoft.zhuangjialong.integration.activity.model.BaseActivityShop;
import com.mfangsoft.zhuangjialong.integration.activity.service.ActivityService;
import com.mfangsoft.zhuangjialong.integration.order.model.BaseOrder;
import com.mfangsoft.zhuangjialong.integration.permission.model.PermissionEntity;
import com.mfangsoft.zhuangjialong.integration.user.model.UserEntity;
import com.mfangsoft.zhuangjialong.integration.user.service.UserService;



@Controller
@RequestMapping("/app")
public class EntryActivityController {
	
	
	@Autowired
	private EntryActivityService entryActivityService; 
	
	/**
	 * 活动报名
	 * @param baseActivityInfo
	 * @return
	 */
	
	@RequestMapping(value="/addEntryActivity",method=RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public ResponseMessage<String> addEntryActivity(@RequestBody BaseEntryActivity baseEntryActivity){
		ResponseMessage<String> message = new ResponseMessage<String>();
		try {
			
			/*BaseEntryActivity baseEntryActivity =new BaseEntryActivity();*/
			baseEntryActivity.setEgg_ticket(0);
			baseEntryActivity.setEgg_use_num(0);
			baseEntryActivity.setLottery_ticket(0);
			baseEntryActivity.setLottery_use_num(0);
			baseEntryActivity.setConsume(0);
			baseEntryActivity.setConsume(0);
			baseEntryActivity.setReserved(0);//审核状态
			baseEntryActivity.setCard(0);
			entryActivityService.addEntryActivity(baseEntryActivity);//活动报名
	
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
		}
		return message;
		
		
	}
	/**
	 * 活动报名人列表
	 * @param baseActivityInfo
	 * @return
	 */
	@RequestMapping(value="/selectEntryActivityPage",method=RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public Page<BaseEntryActivity> selectEntryActivityPage(@RequestBody Page<BaseEntryActivity> page) throws ParseException{
		
		return entryActivityService.selectEntryActivity(page);
	}
	
	
}
